<?php
$sDescriptions = TimeHandler::getMissionDescriptionHistory(@$_REQUEST['iMissionID']);
$oClients = ClientHandler::getClients();
$oMissions = MissionHandler::getMissions(@$_REQUEST['iJob']);
?>
<div id="layer_time_add_clients" class="hidden" style="visibility: visible;" method="post">
<form action="index.php" name="form_time_add">
<input type="hidden" name="sView" value="<?php print $_SESSION['sLastBigView'] ?>">
<input type="hidden" name="sAction" value="time-add">
<input type="hidden" name="sSerial" value="<?php print $oClients[$_REQUEST['iClient']]->sSerial ?>">
<input type="hidden" name="iJob" value="<?php print $_REQUEST['iJob'] ?>">
<input type="hidden" name="iMissionID" value="<?php print $_REQUEST['iMissionID'] ?>">
<table class="boxborder" cellspacing="0">
	<tr>
		<td class="boxhandle" colspan="2"><?php print msg('Register time') ?></td>
	</tr>
	<tr>
		<td class="boxbody" colspan="2">
			<?php print msg('Client') ?>: <?php print $oClients[$_REQUEST['iClient']]->sName ?><br>
			<?php print msg('Worknumber') ?>: <?php print $oClients[$_REQUEST['iClient']]->sSerial ?><br>
		</td>
	</tr>
	<tr>
		<td class="listtop"><?php print msg('Description') ?></td>
		<td class="listtop center"><?php print msg('Date') ?></td>
	</tr>
	<tr>
		<td class="listentity" style="height: 1px;"><input type="text" id="focus_time_add_final" size="40" name="sDescription" value="<?php print htmlspecialchars(@$oMissions[$_REQUEST['iMissionID']]->sTodo) ?>"></td>
		<td class="boxbody clear center vtop" rowspan="2">
			<div style="overflow: scroll; height: 200px; width: 180px;">
			<table style="width: 100%;" cellspacing="0">
<?php
$iNow = mktime();
$iFirstStamp = $iNow - (86400 * 30);
$bFirst = true;
for ($iStamp = $iNow; $iStamp >= $iFirstStamp; $iStamp -= 86400) {
	$sDate = date('Y-m-d', $iStamp);
	$iWeekday = date('w', $iStamp);
	?>
				<tr>
					<td class="missionstatus<?php print ($iWeekday == 0 || $iWeekday == 6 ? '3' : '0') ?> small"><?php print @$sWeekday ?>
						<input type="text" size="1" name="iHours[<?php print $sDate ?>]" value="<?php print ($bFirst ? '8' : '0') ?>" <?php print ($sDate == date('Y-m-d') ? 'checked' : '') ?>> <?php print $sDate.' ('.date('D', $iStamp) ?>)<br>
					</td>
				</tr>
	<?php
	$bFirst = false;
}
?>
			</table>
			</div>
		</td>
	</tr>
	<tr>
		<td class="boxbody vtop">
			<table class="boxborder" cellspacing="0" style="width: 100%;">
				<tr>
					<td class="boxhandle small"><?php print msg('Previous descriptions for this task') ?></td>
				</tr>
<?php
foreach ($sDescriptions as $sThisDescription) {
	?>
				<tr>
					<td class="listentity small"><a href="#" onClick="javascript: document.form_time_add.sDescription.value = '<?php print str_replace('"', '&quot;', addslashes($sThisDescription)) ?>';"><?php print $sThisDescription ?></a></td>
				</tr>
	<?php
}

if (count($sDescriptions) == 0) {
	?>
				<tr>
					<td class="listentity small center">[ <?php print msg('None') ?> ]</td>
				</tr>
	<?php
}
?>
			</table>
		</td>
	</tr>
	<tr>
		<td class="clear small" colspan="2">
			<table style="width: 100%;" cellspacing="0">
				<tr>
					<td class="boxbody">
						<input type="checkbox" name="bOvertime" value="1" onClick="document.form_time_add.bDriving.checked = false;"> <?php print msg('Overtime') ?><br>
					</td>
					<td class="boxbody right">
						<input type="text" name="iDriving" size="2" maxlength="2" value="0"> <?php print msg('Driving') ?>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="boxbody center" colspan="2">
			<input type="submit" value="<?php print msg('OK') ?>">
			<input type="button" value="<?php print msg('Cancel') ?>" onClick="layerHide('layer_time_add_clients');">
		</td>
	</tr>
</table>
</form>
</div>
